---
title: Resolve an external user and its primary contact
summary: GetExternalUser end-to-end process on SAIF.Services.WCF.Services.Security.SecurityService.
status: draft
owner: SAIF Doc Gen
last_reviewed: 2026-09-22
operation_id: OP-021
trigger: Caller invokes `GetExternalUser` over the `Security` route.
---

# OP-021: Resolve an external user and its primary contact

GetExternalUser is invoked over the `Security` route on `SAIF.Services.WCF.Services.Security.SecurityService`; this page documents the process end to end, from route dispatch to the message the caller receives.

| Field | Value |
| --- | --- |
| **Operation ID** | OP-021 |
| **Trigger** | Caller invokes `GetExternalUser` over the `Security` route. |
| **Entry operation** | [`GetExternalUser`](../contracts/security-service.md#getexternaluser) |
| **Owning component** | `SAIF.Services.WCF.Services.Security.SecurityService.GetExternalUser` |
| **Inputs** | Request message parts listed below |
| **Outputs** | An `ExternalUser` projection with its primary user type and contact populated. |
| **Failure behavior** | Generic SOAP fault, per [Faults and error pipeline](../faults.md) |

## Request and response

| Direction | Element | Type | Declared in | Notes |
| --- | --- | --- | --- | --- |
| Request | `userId` | `string` | BCL (`System`) | External-user identifier to resolve. (Yes) |
| Response | `ExternalUser` | `ExternalUser` | External contracts assembly (`SAIF.Services.WCF.Contracts` / framework closure) ** | An `ExternalUser` projection with its primary user type and contact populated. |

<!-- Types declared in `SAIF.Services.WCF.Contracts` are attributed to `SAIF.Framework.Core`, inferred from source and package references and marked `*`; their members are not enumerated because the external declaration was not read, marked `**`. -->

## Steps

1. `LogRequestDetails` logs the operation name and arguments ([BR-WCF-032](../business-rules.md#br-wcf-032-every-security-operation-logs-its-request)).
2. `TryGetExternalUser` queries `ExternalUser` by upper-cased user id; a miss returns `null`; the projection maps `IsActive` from `IsAuthorizedUser` and `IsAccountLocked` from its negation ([BR-WCF-019a](../business-rules.md#br-wcf-019a-external-user-active-and-locked-state-derived-from-one-flag)).
3. The primary user type (`UserTypes.FirstOrDefault(x => x.IsPrimary)`) sets `IsInjuredWorker` when its code is one of `WORK`, `GUARD`, `POWA`, and populates `PrimaryUserType`, defaulting the two description fields to `""` ([BR-WCF-020a](../business-rules.md#br-wcf-020a-injured-worker-status-from-primary-user-type-code)).
4. `ContactFactory.CreatePrimaryContact(user.Person)` selects the first active primary address, email, fax (phone code `F`), and non-fax phone, builds the `PersonName`, and normalizes every null string to `""` ([BR-WCF-021a](../business-rules.md#br-wcf-021a-primary-contact-selection-rules), [BR-WCF-033](../business-rules.md#br-wcf-033-projected-contacts-never-return-null-strings)).
5. Return.
   - On failure: an Oracle/NHibernate exception is logged by the installed error handler and surfaced as a generic SOAP fault with exception detail included.

## Process flow

The following diagram visualizes this process's control flow.

```mermaid
flowchart TD
    A["Log request details"]
    B["Query ExternalUser by<br>upper-cased user id"]
    C["Determine primary user type<br>and injured worker status"]
    D["Build primary contact projection"]
    E["Return."]
    A --> B
    B --> C
    C --> D
    D --> E
```

## Transaction and side effects

| Aspect | Finding |
| --- | --- |
| Unit of work | `OracleUnitOfWorkFactory` (`EXTUR`) |
| Commit point | Not applicable — read only |
| Records written | `ExternalUser`, `ExternalUserType`, `Person`, `Address`, `Phone` (read only) |
| Downstream calls | None |
| Shared state touched | None |
| Repeat-call behavior | Idempotent read |

## Logging

| Surface | Written content |
| --- | --- |
| `HttpContext.Current.Response.AppendToLog` (`LogRequestDetails`) | Writes IIS request-detail log lines when `LOG_REQUEST_DETAILS` is enabled |
| `ErrorLogErrorHandler` → `LogService` | Failure-path exception logging only, carrying method signature, calling user and exception detail; see [Faults and error pipeline](../faults.md) |

## Faults and error handling

| Failure | Fault type the caller receives | Produced by | Source |
| --- | --- | --- | --- |
| Oracle/NHibernate exception | `Generic SOAP fault` | The `ErrorLogErrorHandler` installed by `[LogErrorBehavior]` | src/WCF/SAIF.Services.WCF.Host/Services/Security/Users/UserFactory.cs |

## Authorization

| Requirement | Enforced by | Source | Applies to |
| --- | --- | --- | --- |
| [None in code](../authentication-authorization.md#authorization-enforcement) | IIS authentication on the deployment (see [Activation and hosting](../activation-hosting.md)) | `src/WCF/SAIF.Services.WCF.Host/Services/Security/SecurityService.cs` | This operation |

## Related documentation
- [Index](../index.md)
- [Overview](../overview.md)
- [Architecture](../architecture.md)
- [Activation and hosting](../activation-hosting.md)
- [Operations](../operations.md)
- [Faults and error pipeline](../faults.md)
- [Authentication and authorization](../authentication-authorization.md)
- [Dependencies](../dependencies.md)
- [Configuration](../configuration.md)
- [Operations and processes](../operations-processes.md)
- [Business rules](../business-rules.md)
- [Data model](../data-model.md)
- [Operational runbook](../operational-runbook.md)
- [Tech debt](../tech-debt.md)

> **Note:** Statements marked with `*` were inferred from code structure, naming
> conventions, or contextual evidence where direct confirmation was not available
> in source artifacts. Statements marked with `**` could not be confirmed; treat
> as unknown until verified.

## Sources
- src/WCF/SAIF.Services.WCF.Host/Services/Security/SecurityService.cs
- src/WCF/SAIF.Services.WCF.Host/Services/Security/Users/UserFactory.cs
